package com.helloandroid.view

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.LinearLayout
import com.helloandroid.tools.MyLog
import java.lang.Exception

class LLayoutExt @JvmOverloads constructor(
        ctx: Context,
        attrs: AttributeSet? = null,
        defStyle: Int = 0
) : LinearLayout(ctx, attrs, defStyle) {


    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {

        MyLog.elog("==============================")
        if(ev?.action?:1 == 0){
            val e = Exception()
            e.stackTrace.forEach {
                MyLog.elog(it.toString())
            }
        }
        MyLog.elog("==============================")


        MyLog.elog("LLayoutExt->dispatchTouchEvent called!")
        MyLog.elog("action:${ev?.let { it.action }}")
        val retValue =  super.dispatchTouchEvent(ev)
        MyLog.elog("retValue:$retValue}")
        return retValue
    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        MyLog.elog("LLayoutExt->onInterceptTouchEvent called!")
        MyLog.elog("action:${ev?.let { it.action }}")
        val retValue =  super.onInterceptTouchEvent(ev)
        MyLog.elog("retValue:$retValue}")
        return retValue
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        MyLog.elog("LLayoutExt->onTouchEvent called!")
        MyLog.elog("action:${event?.let { it.action }}")
        val retValue =  super.onTouchEvent(event)
        MyLog.elog("retValue:$retValue}")
        return retValue
    }
}
